package cn.freeprogrammer.igen;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

import cn.freeprogrammer.igen.generator.FreeGenerator;

/**
 * FreeGen的ANT任务.
 * 
 * @author minwh
 *
 */
public class FreeGenAntTask extends Task {
	private String configfile;

	public void execute() {
		try {
			if ((configfile == null) || (configfile.length() == 0)) {
				throw new BuildException("Needs argument configfile.");
			}

			FreeGenerator freeGenerator = new FreeGenerator(configfile);
			freeGenerator.generate();
			
			System.out.println("Finish.");
		} catch (Exception e) {
			throw new BuildException(e);
		}
	}

	public String getConfigfile() {
		return configfile;
	}

	public void setConfigfile(String configfile) {
		this.configfile = configfile;
	}
}
